<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="userName">

<script>
    var obj = {
        password: 123456
    };

    Object.defineProperty(obj, 'userName', {
        get: function () {
            console.log("get");
        },
        set: function () {
            console.log('set');
        }
    });


    var input = document.getElementById('userName');

    input.addEventListener('keyup',function (e) {
        obj.userName= e.target.value;

    })



</script>
</body>
</html>